LogItem = new Class({
	
	Implements : [Options,Events],
	
	options : {
		'animDelay' : '25',
		'glitchChars' : ['@','*','+','[',']','~','^','=','_','/',':',';','\\']
	},
	
	private : {
		'animPeriodical' : null
	},
	
	/**
	 * Text for log item to display
	 * @var String
	 */
	logText : '',
	
	/**
	 * List Item Element to attach to page
	 * @var Element
	 */
	logListItem : null,
	
	/**
	 * Class Constructor
	 */
	initialize : function(logText,options){
		this.logText = logText;
		this.logListItem = new Element("li");
		return this;
	},

	/**
	 * Magic method invoked when class treated like an element
	 */
	toElement : function(){
		return this.logListItem;
	},
	
	/**
	 * Render/animate the text inside the log item
	 */
	render : function(){
		this.private.animPeriodical = this.animateLog.periodical(this.options.animDelay,this);
	},
	
	/**
	 * Add a single letter to string in process of being animated
	 */
	animateLog : function(){
		var animLen = (this.logText).toString().length;
		var curLen = this.logListItem.get('html').length;
		if(curLen==animLen){ // animated all letters, clear periodical
			$clear(this.private.animPeriodical);
			this.private.animPeriodical = null;
			this.logListItem.set('html',this.logText); // get rid of any outstanding glitch letters
			this.fireEvent('complete');
		}else{
			if(curLen % 2){
				this.logListItem.set('html',this.logListItem.get('html')+this.options.glitchChars.getRandom()); // add a random glitch letter for cool effect
			}else{
				this.logListItem.set('html',this.logText.substr(0,curLen+1));
			}
		}
	},
	
	/**
	 * Append text to end of existing log item
	 */
	append : function(text){
		this.logText += text;
		if(this.private.animPeriodical===null) this.render(); // only start animation if not already animating
	}
});